// https://github.com/mancuoj/juejin-markdown-theme-Chinese-red

$baseColor: #f33b1f; // 极光红
$strongColor: #ee3f4d; // 茶花红
$darkBaseColor: #ac1f18; // 覆盆子红
$blockquoteColor: #f07c82; // 香叶红
$codeColor: #ee2746; // 淡曙红
$codeBgColor: #f9f1db; // 蚌肉白
$aColor: #1781b5; // 釉蓝
$bgColor: #fff9f9;

.markdown-body {
  overflow-x: hidden;
  font-size: 17px;
  font-weight: 400;
  line-height: 2;
  color: #212121;
  word-break: break-word;

  // 粗体
  strong {
    padding: 1px;
    color: $strongColor;
  }

  // 斜体
  em {
    padding: 0 2px;
    color: $baseColor;
  }

  // 标题
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    position: relative;
    margin-top: 30px;
    margin-bottom: 20px;
    font-weight: bold;

    line-height: 1.5;
  }

  h1 {
    padding-bottom: 5px;
    font-size: 32px;
    color: $darkBaseColor;
    text-align: center;

    &::after {
      display: block;
      width: 100px;
      height: 2px;
      margin: 4px auto 0;
      content: '';
      border-bottom: 2px solid $baseColor;
    }
  }

  h2 {
    font-size: 28px;
    border-bottom: 1px solid $baseColor;

    &::before {
      color: $baseColor;
      content: '# ' !important;
    }
  }

  h3 {
    padding-left: 9px;
    font-size: 24px;
    border-left: 6px solid $baseColor;
  }

  h4 {
    font-size: 20px;
  }

  // 图片
  img {
    display: block;
    max-width: 280px;
    margin: auto;
  }

  // 分割线
  hr {
    margin: 16px 0;
    border-top: 1px solid #bbbbbb;
    border-right: none;
    border-bottom: none;
    border-left: none;
  }

  // 行间代码
  code {
    padding: 1px 2px;
    overflow-x: auto;
    font-size: 16px;
    color: $codeColor;

    word-break: break-word;

    background-color: $codeBgColor;
    border-radius: 2px;
  }

  // 代码框
  pre {
    position: relative;
    overflow: auto;
    line-height: 1.75;

    > code {
      display: block;

      padding: 16px 12px;
      margin: 12px 0 !important;
      overflow-x: auto;
      font-size: 15px;
      color: #333;
      word-break: normal;
      background: #f7f7f7;
      border-radius: 3px;
    }
  }

  // 链接
  a {
    padding: 0 2px;
    color: $aColor;
    text-decoration: none;
    border-bottom: 1px solid $aColor;

    &:hover,
    &:active {
      color: $darkBaseColor;
      border-bottom: 2px solid $baseColor;
    }
  }

  // 引用
  blockquote {
    padding: 6px 16px;
    margin: 16px 0;
    color: #3d3d3d;
    background-color: $bgColor;
    border-left: 3px solid $blockquoteColor;

    &::after {
      display: block;
      content: '';
    }

    & > p {
      margin: 6px 0;
    }
  }

  // 有序 & 无序列表
  ol,
  ul {
    padding-left: 30px;

    li {
      margin-bottom: 6px;

      & .task-list-item {
        list-style: none;

        ul,
        ol {
          margin-top: 6px;
        }
      }
    }

    ul,
    ol {
      margin-top: 6px;
    }
  }

  ol li {
    padding-left: 6px;
  }

  ::marker {
    color: $baseColor;
  }

  // 任务列表
  .contains-task-list {
    padding-left: 0;
  }

  .task-list-item {
    list-style: none;

    input[type='checkbox'] {
      position: relative;

      &::before {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1;
        box-sizing: border-box;
        content: '';
        background: white;
        border: 1px solid $blockquoteColor;
        border-radius: 3px;
      }

      &:checked {
        &::after {
          position: absolute;
          top: -5px;
          right: 0;
          bottom: 0;
          left: 0;
          z-index: 2;
          width: 0;
          height: 0;
          font-size: 16px;
          font-weight: bold;
          color: $baseColor;
          content: '\2713';
        }
      }
    }
  }

  // 表格
  table {
    display: inline-block !important;
    width: auto;
    max-width: 100%;
    overflow: auto;
    font-size: 14px;

    border-spacing: 0;
    border-collapse: collapse;

    thead {
      font-size: 15px;
      color: black;
      text-align: left;
      background: $bgColor;
    }

    tr:nth-child(2n) {
      background-color: #fcfcfc;
    }

    tr:hover {
      background-color: $bgColor;
    }

    th,
    td {
      padding: 12px 7px;
      line-height: 24px;
      border: 1px solid $codeBgColor;
    }

    td {
      min-width: 120px;
    }
  }

  @media (max-width: 720px) {
    h1 {
      font-size: 24px;
    }

    h2 {
      font-size: 20px;
    }

    h3 {
      font-size: 18px;
    }
  }
}
